<?php
/**
 * LK 参数处理类
 * @ category   LK
 * @ package  LK
 * @ subpackage  core
 * @ yangzhiguo www.amiaoagou.com <yangzhiguo0903@163.com>
 * @ version  $Id$
 */
defined('IN_LK') or die('Access Denied');
class param
{
	/**
	 * 默认参数设置
	 */
	private $config = array();
	
	public function __construct()
	{
		if(!get_magic_quotes_gpc())  //未开启自动转义
		{
			if(isset($_POST))
			{
				$_POST = new_addslashes($_POST);
			}
			if(isset($_GET))
			{
				$_GET = new_addslashes($_GET);
			}
			if(isset($_REQUEST))
			{
				$_REQUEST = new_addslashes($_REQUEST);
			}
			if(isset($_COOKIE))
			{
				$_COOKIE = new_addslashes($_COOKIE);
			}
		}
		
		$this->config = lk::lc('base');
		//额外参数处理
		if(isset($this->config['data']) && !empty($this->config['data']) && is_array($this->config['data']))
		{
			foreach($this->config['data'] as $_key => $_value)
			{
				if(!isset($_POST[$_key]))
				{
					$_POST[$_key] = $_value;
				}
			}
		}
	}
	
   /**
    * 根据URL参数获取模型,控制器,方法
    */
	public function get_param()
	{
		$param = $this->config['default'];
		if($this->config['url_mode'] == 1)
		{
			if(isset($_GET['m']) && !empty($_GET['m']))
			{
				$param['m'] = $_GET['m'];
			}
			if(isset($_GET['c']) && !empty($_GET['c']))
			{
				$param['c'] = $_GET['c'];
			}
			if(isset($_GET['a']) && !empty($_GET['a']))
			{
				$param['a'] = $_GET['a'];
			}
		}
		return $param;
	}
}